#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
class MyCalendarTwo {
public:
    MyCalendarTwo() {

    }

    bool book(int startTime, int endTime) {
        for (auto& e : over)
            if (e.first<endTime && e.second>startTime)
                return false;
        for (auto& e : vec)
            if (e.first<endTime && e.second>startTime)
                over.emplace_back(max(startTime, e.first), min(endTime, e.second));
        vec.emplace_back(startTime, endTime);
        return true;
    }
    vector<pair<int, int>> vec,over;
};

/**
 * Your MyCalendarTwo object will be instantiated and called as such:
 * MyCalendarTwo* obj = new MyCalendarTwo();
 * bool param_1 = obj->book(startTime,endTime);
 */

/**
 * Your MyCalendarTwo object will be instantiated and called as such:
 * MyCalendarTwo* obj = new MyCalendarTwo();
 * bool param_1 = obj->book(startTime,endTime);
 */